<script setup>
import { ref } from "vue";
const todoText = ref("");
const emit = defineEmits(["addTodo"]);

const addTodo = () => {
  if (!todoText.value.length) return;

  emit("addTodo", {
    id: new Date().getTime(),
    content: todoText.value,
    completed: false,
  });

  todoText.value = "";
};
</script>

<template>
  <div>
    <input type="text" placeholder="Pleace input something." v-model="todoText" />
    <button @click="addTodo">ADD</button>
  </div>
</template>

